package com.zjpavt.client.util;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 客户端配置文件
 * @author zjpavt
 */
public class ClientConfig {

    /* * * * * * * * *
     * ==============*
     *   客户端配置	 *
     * ==============*
     * * * * * * * * */

    /* * * * * * * * *
     * ==============*
     * 文件夹路径		 *
     * ==============*
     * * * * * * * * */
    static{
        if (isWindows()) {
            ClientConfig.PAVT_PATH = "C:/oldD/tempPavt/";
            ClientConfig.ROOT_PATH = "C:/oldD/tempPavt/root_pavt/";
        } else {
            ClientConfig.PAVT_PATH = "/pavt/";
            ClientConfig.ROOT_PATH = "/root/";
        }
    }
    /**
     * 设备版本号
     */
    public final static String VERSION = "253.6";
    /**
     * 服务端ip
     */
    public final static String SERVER_IP = "device.zjpavt.com";
    /**
     * 服务端端口
     */
    public final static int PORT = 1983;
    /**
     * 文件读写默认编码
     */
    public static final String DEFAULT_ENCODING = "UTF-8";
    /**
     * udp地址
     */
    public static final String OUTPUT_UDP_ADDR = "192.168.123.156";
    /**
     * udp端口
     */
//	public static final int OUTPUT_UDP_PORT = 6454;
    /**
     * udp端口(server)
     */
    public static final int OUTPUT_UDP_SERVER_PORT = 6464;
    /**
     * udp端口(art net server)
     * 用于接收artnet信号
     */
    public static final int OUTPUT_UDP_ART_NET_SERVER_PORT = 6454;
    /**
     * udp通信ip(server)
     */
    public static final String OUTPUT_UDP_SERVER_IP = "127.0.0.1";



    public static boolean isWindows() {
        String key = "os.name";
        String windows = "Windows";
        if (System.getProperty(key).contains(windows)) {
            return true;
        } else {
            return false;
        }

    }
    /**
     * 根目录
     */
    public static String PAVT_PATH;

    /**
     * 根目录
     */
    public static String ROOT_PATH;

    /**
     * 存储配置文件的位置
     */
    public static final String CONFIG_PATH = PAVT_PATH + "conf/";
    /**
     * 临时文件路径
     */
    public static final String TEMP_PATH = PAVT_PATH + "tmp/";
    /**
     * 最终存储客户端的位置
     */
    public static final String CLIENT_PATH = PAVT_PATH + "bin/";
    /**
     * 最终存储客户端的位置
     */
    public static final String PAVT_SH = PAVT_PATH + "sh/";
    /**
     * log的打印路径
     */
    public static final String CLIENT_LOG_PATH = PAVT_PATH + "log/client";
    /**
     * log的打印路径
     */
    public static final String LOG_PATH = PAVT_PATH + "log/";
    /**
     * log的打印路径
     */
    public static final String _4G_SHELL_PATH = "/root/pavt/sh/4g.sh";
    /**
     * apn改变4g网络地址
     */
    public static final String _4G_APN_SHELL_PATH = "/root/pavt/apn/apn.sh";
    /**
     * 离线指令存储目录
     */
    public static final String OFFLINE_COMMAND_SAVE_PATH = PAVT_PATH + "offlineCommand/";

    /**
     * 设置回路开启/关闭间隔时间，设置网络模式
     */
    public static final String STORE_KEY_CODE = PAVT_PATH + "tmp/keycode.txt";

    /* * * * * * * * * * * * *
     * ======================*
     * 配置文件路径 & prop文件名 *
     * ======================*
     * * * * * * * * * * * * */
    /**
     * 配置文件名称
     */
    public static final String CONFIG_NAME = "clientConfig.properties";
    /**
     * 设备状态文件名称
     */
    public static final String DEVICE_STATUS_CONFIG_NAME = "clientStatus.properties";
    /**
     * 当天定时器文件名称
     */
    public static final String DEVICE_TIMER_CONFIG_NAME = "deviceTimer.properties";
    /**
     * 更新配置文件名称
     */
    public static final String UPDATE_CONFIG_NAME = "updateConfig.properties";
    /**
     * dmx配置文件名称
     */
    public static final String DMX_CONFIG_PROPERTIES = "dmxConfig.properties";
    /**
     * artNet输出文件名称
     */
    public static final String ART_NET_CONFIG_PROPERTIES = "artnet.properties";
    /**
     * 视频服务器文件名称
     */
    public static final String VIDEO_SERVER = "video.properties";

    /**
     * y指令读取的ID密码段的路径（暂时未定）
     */
    public static final String ID_PWD_SAVE_PATH = null;

    /* * * * * * * * *
     * ==============*
     * 设备文件路径	 *
     * ==============*
     * * * * * * * * */
    /**
     * 温度传感器文件路径
     */
    public static final String TMP_SENSOR_DEVICE_FILE_PATH
        = "/sys/bus/i2c/drivers/lm75/0-0048/hwmon/hwmon0/temp1_input";

    /**
     * 风扇文件路径(可能存在多个风扇文件/pwm0   pwm1)
     */
    public static final String FAN_FILE_PATH = "/sys/class/pwm/pwmchip0/";
    /**
     * 风扇开关状态路径
     */
    public static final String FAN_FILE_ENABLE_PATH = FAN_FILE_PATH + "pwm%s/enable";
    /**
     * 风扇运行状态路径
     */
    public static final String FAN_STATE_PATH = "/sys/bus/iio/devices/iio:device0/in_voltage%s_raw";


    /* * * * * * * * *
     * ==============*
     * ini,info文件路径*
     * ==============*
     * * * * * * * * */
    /**
     * GPS和光感路径 以及温度(读取路径)
     */
    public static final String INI_GPS_LUX_PATH = ROOT_PATH + "pavt/info/gps_data.info";

    /**
     * 电能表信息路径(读取路径)
     * 三相电流
     */
    public static final String INI_POWER_PATH = ROOT_PATH + "pavt/info/power_data.info";

    /**
     * 回路电流电压状态信息路径(读取路径)
     * 三相电压
     */
    public static final String INI_CIR_PATH = ROOT_PATH + "pavt/info/cir_data.info";
    /**
     * 设备拓展通道上的设备读取
     */
    public static final String INI_EXTEND_PATH = ROOT_PATH + "pavt/info/ex_uart.info";

    /**
     * 设备ID属性读取
     */
    public static final String INI_DEVICE_ID_PATH = ROOT_PATH + "pavt/info/id_data.info";

    /**
     * 空气开关属性读取
     */
    public static final String INI_AIR_SWITCH_PATH = ROOT_PATH + "pavt/info/airswitch_data.info";
    /**
     * 温湿度传感器的属性读取
     */
    public static final String INI_TEMPERATURE_PATH = ROOT_PATH + "pavt/info/tmp_data.info";
    /**
     * 系统设置信息
     */
    public static final String INI_P437X_PATH = ROOT_PATH + "pavt/ini/pavt.ini";
    /**
     * 系统网络配置信息
     */
    public static final String SYSTEM_INI_PATH = ROOT_PATH + "pavt/ini/system.ini";
    /**
     * 系统Mac信息
     */
    public static final String MAC_INI_PATH = ROOT_PATH + "pavt/ini/mac_addr.ini";
    /**
     * 默认波特率
     */
    public static final int DEFAULT_BAUD_RATE = 115200;
    /**
     * 默认超时时间
     */
    public static final int DEFAULT_BAUD_RATE_OUTTIME = 200;



    public static final boolean TEST_MODE_CHANGE_CHANNEL_ALWAYS = false;

    static {

    }
}
